package xyz.migle.sc.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

//@SpringBootApplication
//@EnableDiscoveryClient
//@RestController
public class ScApp001LB {
//    @Autowired
//    LoadBalancerClient loadBalancerClient;
//    //@Autowired
//    RestTemplate restTemplate = new RestTemplate();
//
//    @RequestMapping("/lb")
//    public String homeLB() {
//        ServiceInstance serviceInstance = loadBalancerClient.choose("sc-demo-base-001");
//        //String url = "http://" + serviceInstance.getHost() + ":" + serviceInstance.getPort() + "/dc";
//        String url = serviceInstance.getUri().toString();
//        System.out.println(url);
//        return "i am sc-demo-app-001,i depend on "+ url +":" + restTemplate.getForObject(url, String.class);
//
//    }
//
////    @Bean
////    public RestTemplate restTemplate() {
////        return new RestTemplate();
////    }
//
//    public static void main(String[] args) {
//         SpringApplication.run(ScApp001LB.class,args);
//    }

}

